/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package reamodel.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import reamodel.Commitment;
import reamodel.EconomicAgent;
import reamodel.EconomicAgentType;
import reamodel.EconomicEvent;
import reamodel.EconomicEventType;
import reamodel.EconomicResource;
import reamodel.EconomicResourceType;
import reamodel.REAModel;
import reamodel.ReamodelPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>REA Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link reamodel.impl.REAModelImpl#getResourceTypes <em>Resource Types</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getEventTypes <em>Event Types</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getAgentTypes <em>Agent Types</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getResources <em>Resources</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getEvents <em>Events</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getAgents <em>Agents</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getCommitments <em>Commitments</em>}</li>
 *   <li>{@link reamodel.impl.REAModelImpl#getDescription <em>Description</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class REAModelImpl extends EObjectImpl implements REAModel {
	/**
	 * The cached value of the '{@link #getResourceTypes() <em>Resource Types</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResourceTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicResourceType> resourceTypes;

	/**
	 * The cached value of the '{@link #getEventTypes() <em>Event Types</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEventTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicEventType> eventTypes;

	/**
	 * The cached value of the '{@link #getAgentTypes() <em>Agent Types</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAgentTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicAgentType> agentTypes;

	/**
	 * The cached value of the '{@link #getResources() <em>Resources</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResources()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicResource> resources;

	/**
	 * The cached value of the '{@link #getEvents() <em>Events</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEvents()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicEvent> events;

	/**
	 * The cached value of the '{@link #getAgents() <em>Agents</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAgents()
	 * @generated
	 * @ordered
	 */
	protected EList<EconomicAgent> agents;

	/**
	 * The cached value of the '{@link #getCommitments() <em>Commitments</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCommitments()
	 * @generated
	 * @ordered
	 */
	protected EList<Commitment> commitments;

	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected REAModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ReamodelPackage.Literals.REA_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicResourceType> getResourceTypes() {
		if (resourceTypes == null) {
			resourceTypes = new EObjectContainmentEList<EconomicResourceType>(EconomicResourceType.class, this, ReamodelPackage.REA_MODEL__RESOURCE_TYPES);
		}
		return resourceTypes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicEventType> getEventTypes() {
		if (eventTypes == null) {
			eventTypes = new EObjectContainmentEList<EconomicEventType>(EconomicEventType.class, this, ReamodelPackage.REA_MODEL__EVENT_TYPES);
		}
		return eventTypes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicAgentType> getAgentTypes() {
		if (agentTypes == null) {
			agentTypes = new EObjectContainmentEList<EconomicAgentType>(EconomicAgentType.class, this, ReamodelPackage.REA_MODEL__AGENT_TYPES);
		}
		return agentTypes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicResource> getResources() {
		if (resources == null) {
			resources = new EObjectContainmentEList<EconomicResource>(EconomicResource.class, this, ReamodelPackage.REA_MODEL__RESOURCES);
		}
		return resources;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicEvent> getEvents() {
		if (events == null) {
			events = new EObjectContainmentEList<EconomicEvent>(EconomicEvent.class, this, ReamodelPackage.REA_MODEL__EVENTS);
		}
		return events;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EconomicAgent> getAgents() {
		if (agents == null) {
			agents = new EObjectContainmentEList<EconomicAgent>(EconomicAgent.class, this, ReamodelPackage.REA_MODEL__AGENTS);
		}
		return agents;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Commitment> getCommitments() {
		if (commitments == null) {
			commitments = new EObjectContainmentEList<Commitment>(Commitment.class, this, ReamodelPackage.REA_MODEL__COMMITMENTS);
		}
		return commitments;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ReamodelPackage.REA_MODEL__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ReamodelPackage.REA_MODEL__RESOURCE_TYPES:
				return ((InternalEList<?>)getResourceTypes()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__EVENT_TYPES:
				return ((InternalEList<?>)getEventTypes()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__AGENT_TYPES:
				return ((InternalEList<?>)getAgentTypes()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__RESOURCES:
				return ((InternalEList<?>)getResources()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__EVENTS:
				return ((InternalEList<?>)getEvents()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__AGENTS:
				return ((InternalEList<?>)getAgents()).basicRemove(otherEnd, msgs);
			case ReamodelPackage.REA_MODEL__COMMITMENTS:
				return ((InternalEList<?>)getCommitments()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ReamodelPackage.REA_MODEL__RESOURCE_TYPES:
				return getResourceTypes();
			case ReamodelPackage.REA_MODEL__EVENT_TYPES:
				return getEventTypes();
			case ReamodelPackage.REA_MODEL__AGENT_TYPES:
				return getAgentTypes();
			case ReamodelPackage.REA_MODEL__RESOURCES:
				return getResources();
			case ReamodelPackage.REA_MODEL__EVENTS:
				return getEvents();
			case ReamodelPackage.REA_MODEL__AGENTS:
				return getAgents();
			case ReamodelPackage.REA_MODEL__COMMITMENTS:
				return getCommitments();
			case ReamodelPackage.REA_MODEL__DESCRIPTION:
				return getDescription();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ReamodelPackage.REA_MODEL__RESOURCE_TYPES:
				getResourceTypes().clear();
				getResourceTypes().addAll((Collection<? extends EconomicResourceType>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__EVENT_TYPES:
				getEventTypes().clear();
				getEventTypes().addAll((Collection<? extends EconomicEventType>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__AGENT_TYPES:
				getAgentTypes().clear();
				getAgentTypes().addAll((Collection<? extends EconomicAgentType>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__RESOURCES:
				getResources().clear();
				getResources().addAll((Collection<? extends EconomicResource>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__EVENTS:
				getEvents().clear();
				getEvents().addAll((Collection<? extends EconomicEvent>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__AGENTS:
				getAgents().clear();
				getAgents().addAll((Collection<? extends EconomicAgent>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__COMMITMENTS:
				getCommitments().clear();
				getCommitments().addAll((Collection<? extends Commitment>)newValue);
				return;
			case ReamodelPackage.REA_MODEL__DESCRIPTION:
				setDescription((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ReamodelPackage.REA_MODEL__RESOURCE_TYPES:
				getResourceTypes().clear();
				return;
			case ReamodelPackage.REA_MODEL__EVENT_TYPES:
				getEventTypes().clear();
				return;
			case ReamodelPackage.REA_MODEL__AGENT_TYPES:
				getAgentTypes().clear();
				return;
			case ReamodelPackage.REA_MODEL__RESOURCES:
				getResources().clear();
				return;
			case ReamodelPackage.REA_MODEL__EVENTS:
				getEvents().clear();
				return;
			case ReamodelPackage.REA_MODEL__AGENTS:
				getAgents().clear();
				return;
			case ReamodelPackage.REA_MODEL__COMMITMENTS:
				getCommitments().clear();
				return;
			case ReamodelPackage.REA_MODEL__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ReamodelPackage.REA_MODEL__RESOURCE_TYPES:
				return resourceTypes != null && !resourceTypes.isEmpty();
			case ReamodelPackage.REA_MODEL__EVENT_TYPES:
				return eventTypes != null && !eventTypes.isEmpty();
			case ReamodelPackage.REA_MODEL__AGENT_TYPES:
				return agentTypes != null && !agentTypes.isEmpty();
			case ReamodelPackage.REA_MODEL__RESOURCES:
				return resources != null && !resources.isEmpty();
			case ReamodelPackage.REA_MODEL__EVENTS:
				return events != null && !events.isEmpty();
			case ReamodelPackage.REA_MODEL__AGENTS:
				return agents != null && !agents.isEmpty();
			case ReamodelPackage.REA_MODEL__COMMITMENTS:
				return commitments != null && !commitments.isEmpty();
			case ReamodelPackage.REA_MODEL__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (description: ");
		result.append(description);
		result.append(')');
		return result.toString();
	}

} //REAModelImpl
